<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">		
		<link href="${pageContext.request.contextPath}/css/globaltd.css"
			rel="stylesheet" type="text/css">
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/js/jquery-1.3.2.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/js/My97DatePicker/WdatePicker.js"></script>
		<script >
			function removeAb(id){
				if(confirm("确认删除专辑？")){
					window.location.href="${pageContext.request.contextPath}/removeAblum.action?id="+id;
				}				
			}
		</script>	
	<body>
		<div class="wrapper">
			<div class="container">
				<div class="nav" id="navText">
					专辑管理
				</div>
				<form id="form1" action="${pageContext.request.contextPath}/ablumIndex.action" method="post">
				<div class="tag">
					<table class="search-tab" cellpadding="0" cellspacing="0">
						<tbody>
							<tr>
								<th>
									专辑标题:
								</th>
								<td>
									<input type="text" name="title" id="title" value="${param.title}" />
								</td>
								<th>
									时间范围:
								</th>
								<td>
									<input class="Wdate" size="20" type="text"
										onClick="WdatePicker()" id="beginDate" name="beginDate"
										value="${params.beginDate}" />
									至
									<input class="Wdate" size="20" type="text"
										onClick="WdatePicker()" id="endDate" name="endDate"
										value="${params.endDate}" />
								</td>
								<td>
									<input class="btn" value="查询" id="queryBtn" type="submit">
								</td>
							</tr>
						</tbody>
					</table>
				</div>
				</form>
				
				<div id="tablePanel">
					<table cellspacing="0" cellpadding="0" even="true" class="list">
						<tbody>
							<tr class="even" style="line-height: 30px;">
								<th class="fi">专辑封面</th>
								<th class="fi">专辑标题</th>
								<th class="fi">专辑描述</th>
								<th class="fi">专辑状态</th>
								<th class="fi">专辑类型</th>
								<th class="fi">收费类型</th>
								<th class="fi">产品id</th>
								<th class="fi">收费金额</th>
								<th class="fi">保存时间</th>
								<th class="fi">操作</th>
							</tr>
							<c:forEach items="${dataList}" var="ab" varStatus="stat">
								<c:choose>
									<c:when test="${stat.index%2==0}"><tr></c:when>
									<c:otherwise><tr class="even"></c:otherwise>
								</c:choose>		
									<td>						
									<img width="50" height="50" src="${pageContext.request.contextPath}/uploads/${fn:replace(ab.imageUrl,'D://resin-pro-3.1.8/webapps/qm/uploads/','')}" />
									</td>								
									<td>${ab.title}</td>								
									<td>${ab.remark}&nbsp;</td>								
									<td>
										<c:choose>
											<c:when test="${ab.type==1}">学院类</c:when>
											<c:when test="${ab.type==2}">电影类</c:when>
											<c:when test="${ab.type==3}">明星类</c:when>
											<c:otherwise>未知</c:otherwise>
										</c:choose>
									</td>								
									<td>
										<c:choose>
											<c:when test="${ab.state==1}">未完成</c:when>
											<c:when test="${ab.state==2}">完成</c:when>
											<c:when test="${ab.state==3}">删除</c:when>
											<c:otherwise>未知</c:otherwise>
										</c:choose>									
									</td>								
									<td>
										<c:choose>
											<c:when test="${ab.isFree==1}">免费</c:when>
											<c:when test="${ab.isFree==2}">收费</c:when>
											<c:otherwise>未知</c:otherwise>
										</c:choose>
									</td>								
									<td>${ab.iapid}</td>								
									<td>${ab.value}</td>								
									<td>${ab.saveTime}</td>								
									<td>
									<a href="${pageContext.request.contextPath}/toUpdateAblum.action?id=${ab.id}">编辑</a>
									&nbsp;&nbsp;
									<a href="javascript:removeAb(${ab.id})">删除</a>
									</td>								
								</tr>							
							</c:forEach>								
						</tbody>
					</table>
			<div class="pagin" style="text-align: center">
				<c:if test="${count > 0 }">每页显示<c:out value="${pageSize }" />条　共<c:out value="${count}" />条 </c:if>
				<c:if test="${pageCount > 1 && pageCount < 12}">
					<c:forEach begin="1" end="${pageCount}" step="1" var="i" >
						<c:choose>
							<c:when test="${pageNum==i}">
									<a style="color:#c30f07" href="${pageContext.request.contextPath}/ablumIndex.action?<c:forEach items="${params}" var="item" varStatus="st"><c:out value="${ item.key }"/>=<c:out value="${item.value}" />&</c:forEach>page=<c:out value="${ i }"/>&order=${orderField } ${order }">[<c:out value="${i}" />]</a>
							</c:when>
							<c:otherwise>
										<a href="${pageContext.request.contextPath}/ablumIndex.action?<c:forEach items="${params}" var="item" varStatus="st"><c:out value="${ item.key }"/>=<c:out value="${item.value}" />&</c:forEach>page=<c:out value="${ i }"/>&order=${orderField } ${order }">[<c:out value="${i}" />]</a>
							</c:otherwise>
						</c:choose>						
					</c:forEach>
				</c:if>
				<c:if test="${pageCount >= 12}">
					<c:if test="${pageNum < 7}">
						<c:forEach begin="1" end="10" step="1" var="i" >							
							<c:choose>
								<c:when test="${pageNum==i}">
									<a style="color:#c30f07" href="${pageContext.request.contextPath}/ablumIndex.action?<c:forEach items="${params}" var="item" varStatus="st"><c:out value="${ item.key }"/>=<c:out value="${item.value}" />&</c:forEach>page=<c:out value="${ i }"/>">[<c:out value="${i}" />]</a>
								</c:when>
								<c:otherwise>
									<a href="${pageContext.request.contextPath}/ablumIndex.action?<c:forEach items="${params}" var="item" varStatus="st"><c:out value="${ item.key }"/>=<c:out value="${item.value}" />&</c:forEach>page=<c:out value="${ i }"/>">[<c:out value="${i}" />]</a>
								</c:otherwise>
							</c:choose>							
						</c:forEach>
						... 
						<c:url var="lastPageUrl" value="${pageContext.request.contextPath}/ablumIndex.action?"><c:forEach items="${params}" var="item" varStatus="st"><c:param name="${item.key}" value="${item.value}" /></c:forEach><c:param name="page" value="${pageCount}" /></c:url>
						<a href="${lastPageUrl}">[${pageCount}]</a>
					</c:if>
					<c:if test="${pageNum >= 7}">
						<a href="${pageContext.request.contextPath}/ablumIndex.action?<c:forEach items="${params}" var="item" varStatus="st"><c:out value="${ item.key }"/>=<c:out value="${item.value}" />&</c:forEach>page=1">[1]</a>
						...
						<c:forEach begin="${(pageCount - pageNum) < 7 ? (pageCount - 7) : (pageNum - 2)}" end="${(pageNum + 4) < pageCount ? (pageNum + 4) : (pageCount - 1)}" step="1" var="i" >
							<c:choose>
								<c:when test="${pageNum==i}">
									<a style="color:#c30f07" href="${pageContext.request.contextPath}/ablumIndex.action?<c:forEach items="${params}" var="item" varStatus="st"><c:out value="${ item.key }"/>=<c:out value="${item.value}" />&</c:forEach>page=<c:out value="${ i }"/>">[<c:out value="${i}" />]</a>
								</c:when>
								<c:otherwise>
									<a href="${pageContext.request.contextPath}/ablumIndex.action?<c:forEach items="${params}" var="item" varStatus="st"><c:out value="${ item.key }"/>=<c:out value="${item.value}" />&</c:forEach>page=<c:out value="${ i }"/>">[<c:out value="${i}" />]</a>
								</c:otherwise>
							</c:choose>	
						</c:forEach>
						
						<c:if test="${pageCount - (pageNum + 4) > 1}"> ... </c:if>
						
						<c:url var="lastPageUrl" value="${pageContext.request.contextPath}/ablumIndex.action?">
						<c:forEach items="${params}" var="item" varStatus="st"><c:param name="${item.key}" value="${item.value}" /></c:forEach>
						<c:param name="page" value="${pageCount}" />
						</c:url>						
						<c:choose>
							<c:when test="${pageNum==pageCount}">
								<a style="color:#c30f07" href="${lastPageUrl}">[${pageCount}]</a>							
							</c:when>
							<c:otherwise>
								<a href="${lastPageUrl}">[${pageCount}]</a>							
							</c:otherwise>
						</c:choose>		
					</c:if>
				</c:if>
			</div>						
					
					
					
				</div>
			</div>
		</div>
	</body>
</html>